package day3.Exer;

import java.util.Scanner;

public class Customertest {
    public static void main(String[] args) {
        Customer a=new Customer();
        Scanner in = new Scanner(System.in);
        while(true){
            System.out.println("1.添加客户；2.显示所有客户；3.搜索客户信息；4.查找客户；5.修改客户信息；0.退出。");
            System.out.println("请选择：");
            int chose=in.nextInt();
            switch (chose){
                case 1:{
                    System.out.println("请输入客户姓名：");
                    String custName=in.next();
                    a.add(custName);
                    break;
                }
                case 2:{
                    a.showcust();
                    break;
                }
                case 3:{
                    System.out.print("请输入起点：");
                    int start=in.nextInt();
                    System.out.print("请输入终点：");
                    int end=in.nextInt();
                    System.out.print("找谁：");
                    String custName=in.next();
                    boolean exists=a.searchName(start,end,custName);
                    if(exists){
                        System.out.println(custName+"在顾客信息表中");
                    }else{
                        System.out.println(custName+"顾客信息表中");
                    }
                    break;
                }
                case 4:{
                    System.out.println("请输入您要查找的客户的位置：");
                    int index=in.nextInt();
                    a.find(index);
                    break;
                }
                case 5:{
                    System.out.println("请输入您要修改的位置：");
                    int index=in.nextInt();
                    a.change(index);
                    break;
                }
                case 0:{
                    System.out.println("退出成功");
                    return;
                }
            }
        }
    }
}
